<style>
  .temp-check-drawer-footer{
    width: 100%;
    position: absolute;
    bottom: 0;
    left: 0;
    border-top: 1px solid #e8e8e8;
    padding: 10px 16px;
    text-align: right;
    background: #fff;
  }
</style>
<template>
  <div>
    <Drawer
      :value="modalState"
      :closable="false"
      :title="title"
      @on-close="cancel"
      width="35%">
      <div style="margin-left: 10%; padding: 20px;">
        <div style="padding: 10px;">
          <div style="width: 120px; font-size: 16px; font-weight: bold">短信活动模板：</div>
          <div style="width: 310px; font-size: 14px;">{{`【${row.tag}】${row.content}`}}</div>
        </div>
      </div>
      <Form
        ref="tempCheckDrawer"
        :model="row"
        :label-width="100"
        style="margin-left: 10%; margin-top: 30px;">
        <FormItem prop="state" label="审核状态：" style="width: 300px;">
          <Select v-model="row.state" placeholder="请选择审核状态">
            <Option value="0">
              未审核
            </Option>
            <Option value="1">
              审核通过
            </Option>
            <Option value="2">
              未通过
            </Option>
          </Select>
        </FormItem>
        <FormItem prop="des" label="备注：" style="width: 400px;">
          <Input type="textarea" :rows="6" v-model="row.des" placeholder="请输入备注" />
        </FormItem>
      </Form>
      <div class="temp-check-drawer-footer">
        <Button style="margin-right: 8px" @click="cancel">取消</Button>
        <Button type="primary" @click="handleSubmit">确认</Button>
      </div>
    </Drawer>
  </div>
</template>
<script>
import {
  mapActions,
  mapState
} from 'vuex'
export default {
  name: 'TempCheckDrawer',
  props: {
    row: null,
    modalState: Boolean
  },
  data () {
    return {
      title: '',
      loading: true
    }
  },
  updated () {
    this.title = '短信模板审核'
  },
  methods: {
    changeLoading () {
      this.loading = false
      this.$nextTick(() => {
        this.loading = true
      })
    },
    handleSubmit () {
      this.$refs.tempCheckDrawer.validate((valid) => {
        if (valid) {
          this.$emit('temp-check-valid', {
            drawer: this.$refs['tempCheckDrawer'],
            id: this.row.id,
            state: this.row.state,
            des: this.row.des
          })
        }
      })
    },
    cancel () {
      this.$emit('on-cancel', this.$refs['tempCheckDrawer'])
    }
  }
}
</script>
